<template>

  <div class="app-container">

    <el-row :gutter="20">
      <!--部门数据-->
      <el-col :span="4" :xs="24">
        <div class="head-container">
          <el-input
            v-model="deptName"
            placeholder="请输入部门名称"
            clearable
            size="small"
            prefix-icon="el-icon-search"
            style="margin-bottom: 20px"
          />
        </div>
        <div class="head-container">
          <el-tree
            :data="deptOptions"
            :props="defaultProps"
            :expand-on-click-node="false"
            :filter-node-method="filterNode"
            ref="tree"
            node-key="id"
            default-expand-all
            highlight-current
            @node-click="handleNodeClick"
          />
        </div>
      </el-col>
      <!--用户数据-->
      <el-col :span="20" :xs="24">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="id号" prop="userId">
        <el-input
          v-model="queryParams.userId"
          placeholder="请输入id号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="员工名称" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入员工名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工号" prop="empNumber">
        <el-input
          v-model="queryParams.empNumber"
          placeholder="请输入工号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用户性别" prop="sex">
        <el-select v-model="queryParams.sex" placeholder="请选择用户性别" clearable>
          <el-option
            v-for="dict in dict.type.sys_user_sex"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="身份证" prop="idCard">
        <el-input
          v-model="queryParams.idCard"
          placeholder="请输入身份证"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="身份证号地域" prop="idNumberRegion">
        <el-input
          v-model="queryParams.idNumberRegion"
          placeholder="请输入身份证号地域"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="手机号码" prop="phoneNumber">
        <el-input
          v-model="queryParams.phoneNumber"
          placeholder="请输入手机号码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>


      <el-form-item label="地域" prop="region">
        <el-select v-model="queryParams.sex" placeholder="请输入地域" clearable>
          <el-option
            v-for="dict in dict.type.region"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>



      <el-form-item label="合同签订时间" prop="contractDate">
        <el-date-picker clearable
          v-model="queryParams.contractDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择合同签订时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="合同截至日期" prop="contractLong">
        <el-date-picker clearable
          v-model="queryParams.contractLong"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择合同截至日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="入职时间" prop="date">
        <el-date-picker clearable
          v-model="queryParams.date"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择入职时间">
        </el-date-picker>
      </el-form-item>

      <el-form-item label="社保缴纳情况" prop="typeOfEmployment">
        <el-input
          v-model="queryParams.typeOfEmployment"
          placeholder="请输入社保缴纳情况"
          clearable
          @keyup.enter.native="handleQuery"
        />

      </el-form-item>

      <el-form-item label="用工类型" prop="typeOfMen">
        <el-select v-model="queryParams.typeOfMen" placeholder="请选择人员类型" clearable>
          <el-option
            v-for="dict in dict.type.type_of_men"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="婚姻状态" prop="maritalStatus">
        <el-select v-model="queryParams.maritalStatus" placeholder="请选择婚姻状态" clearable>
          <el-option
            v-for="dict in dict.type.marital_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="政治面貌" prop="politicalLandscape">
        <el-input
          v-model="queryParams.politicalLandscape"
          placeholder="请输入政治面貌"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="住址" prop="address">
        <el-input
          v-model="queryParams.address"
          placeholder="请输入住址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="最高学历" prop="highEducationalLevel">
        <el-select v-model="queryParams.highEducationalLevel" placeholder="请选择最高学历" clearable>
          <el-option
            v-for="dict in dict.type.education"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="毕业学校" prop="school">
        <el-input
          v-model="queryParams.school"
          placeholder="请输入毕业学校"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="学制类型" prop="typeEducation">
        <el-input
          v-model="queryParams.typeEducation"
          placeholder="请输入学制类型"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="专业" prop="major">
        <el-input
          v-model="queryParams.major"
          placeholder="请输入专业"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="民族" prop="nation">
        <el-input
          v-model="queryParams.nation"
          placeholder="请输入民族"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="紧急联系人" prop="emergencyContact">
        <el-input
          v-model="queryParams.emergencyContact"
          placeholder="请输入紧急联系人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="紧急联系人电话" prop="emergencyContactPhone">
        <el-input
          v-model="queryParams.emergencyContactPhone"
          placeholder="请输入紧急联系人电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="第一学历" prop="firstDegree">-->
<!--        <el-input-->
<!--          v-model="queryParams.firstDegree"-->
<!--          placeholder="请输入第一学历"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="第二学历" prop="secondDegree">-->
<!--        <el-input-->
<!--          v-model="queryParams.secondDegree"-->
<!--          placeholder="请输入第二学历"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->

      <el-form-item label="开户行" prop="bank">
        <el-input
          v-model="queryParams.bank"
          placeholder="请输入开户行"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="银行账号" prop="bankAccountNumber">
        <el-input
          v-model="queryParams.bankAccountNumber"
          placeholder="请输入银行账号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="爱好特长" prop="hobby">
        <el-input
          v-model="queryParams.hobby"
          placeholder="请输入爱好特长"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否安排寝室" prop="dormitoryNeed">
        <el-input
          v-model="queryParams.dormitoryNeed"
          placeholder="请输入是否安排寝室"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="寝室号" prop="dormitory">
        <el-input
          v-model="queryParams.dormitory"
          placeholder="请输入寝室号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出生年月" prop="birthday">
        <el-date-picker clearable
          v-model="queryParams.birthday"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择出生年月">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="其他" prop="other">
        <el-input
          v-model="queryParams.other"
          placeholder="请输入其他"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段1" prop="Reserved1">
        <el-input
          v-model="queryParams.Reserved1"
          placeholder="请输入预留字段1"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段2" prop="Reserved2">
        <el-input
          v-model="queryParams.Reserved2"
          placeholder="请输入预留字段2"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段3" prop="Reserved3">
        <el-input
          v-model="queryParams.Reserved3"
          placeholder="请输入预留字段3"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段4" prop="Reserved4">
        <el-input
          v-model="queryParams.Reserved4"
          placeholder="请输入预留字段4"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段5" prop="Reserved5">
        <el-input
          v-model="queryParams.Reserved5"
          placeholder="请输入预留字段5"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段6" prop="Reserved6">
        <el-input
          v-model="queryParams.Reserved6"
          placeholder="请输入预留字段6"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段7" prop="Reserved7">
        <el-input
          v-model="queryParams.Reserved7"
          placeholder="请输入预留字段7"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段8" prop="Reserved8">
        <el-input
          v-model="queryParams.Reserved8"
          placeholder="请输入预留字段8"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['Empment:information:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['Empment:information:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['Empment:information:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['Empment:information:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

        <el-table
          v-loading="loading"
          :data="informationList"
          @selection-change="handleSelectionChange"
          :max-height="maxHeight"
          style="width: 100%;"
          :scroll-y="true"
        >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="员工id号" align="center" prop="userId" fixed />
      <el-table-column label="员工名称" align="center" prop="name" fixed />
      <el-table-column label="工号" align="center" prop="empNumber" />
      <el-table-column label="部门" align="center"  prop="dept.deptName"  />
      <el-table-column label="用户性别" align="center" prop="sex">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.sex"/>
        </template>
      </el-table-column>
      <el-table-column label="身份证" align="center" prop="idCard" />
      <el-table-column label="身份证号地域" align="center" prop="idNumberRegion" />
      <el-table-column label="手机号码" align="center" prop="phoneNumber" />
      <el-table-column label="地域" align="center" prop="region" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.region" :value="scope.row.region"/>
        </template>
      </el-table-column>
      <el-table-column label="合同签订时间" align="center" prop="contractDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.contractDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="合同截至日期" align="center" prop="contractLong" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.contractLong, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="入职时间" align="center" prop="date" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.date, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="社保缴纳情况" align="center" prop="typeOfEmployment"/>
      <el-table-column label="用工类型" align="center" prop="typeOfMen">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.type_of_men" :value="scope.row.typeOfMen"/>
        </template>
      </el-table-column>
      <el-table-column label="婚姻状态" align="center" prop="maritalStatus">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.marital_status" :value="scope.row.maritalStatus"/>
        </template>
      </el-table-column>
      <el-table-column label="政治面貌" align="center" prop="politicalLandscape" />
      <el-table-column label="住址" align="center" prop="address" />

      <el-table-column label="最高学历" align="center" prop="highEducationalLevel" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.education" :value="scope.row.highEducationalLevel"/>
        </template>
      </el-table-column>
      <el-table-column label="毕业学校" align="center" prop="school" />
      <el-table-column label="学制类型" align="center" prop="typeEducation" />
      <el-table-column label="专业" align="center" prop="major" />
      <el-table-column label="民族" align="center" prop="nation" />
      <el-table-column label="紧急联系人" align="center" prop="emergencyContact" />
      <el-table-column label="紧急联系人电话" align="center" prop="emergencyContactPhone" />
<!--      <el-table-column label="第一学历" align="center" prop="firstDegree" />-->
<!--      <el-table-column label="第二学历" align="center" prop="secondDegree" />-->
      <el-table-column label="开户行" align="center" prop="bank" />
      <el-table-column label="银行账号" align="center" prop="bankAccountNumber" />
      <el-table-column label="爱好特长" align="center" prop="hobby" />
      <el-table-column label="是否安排寝室" align="center" prop="dormitoryNeed" />
      <el-table-column label="寝室号" align="center" prop="dormitory" />
      <el-table-column label="出生年月" align="center" prop="birthday" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.birthday, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="其他" align="center" prop="other" />
      <el-table-column label="预留字段1" align="center" prop="Reserved1" />
      <el-table-column label="预留字段2" align="center" prop="Reserved2" />
      <el-table-column label="预留字段3" align="center" prop="Reserved3" />
      <el-table-column label="预留字段4" align="center" prop="Reserved4" />
      <el-table-column label="预留字段5" align="center" prop="Reserved5" />
      <el-table-column label="预留字段6" align="center" prop="Reserved6" />
      <el-table-column label="预留字段7" align="center" prop="Reserved7" />
      <el-table-column label="预留字段8" align="center" prop="Reserved8" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['Empment:information:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['Empment:information:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
      </el-col>
    </el-row>
    <!-- 添加或修改员工信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">

        <el-form-item label="员工名称" prop="name">
          <el-input v-model="form.name" placeholder="请输入员工名称" />
        </el-form-item>
        <el-form-item label="工号" prop="empNumber">
          <el-input v-model="form.empNumber" placeholder="请输入工号" />
        </el-form-item>
        <el-form-item label="归属部门" prop="deptId">
          <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
        </el-form-item>
        <el-form-item label="用户性别" prop="sex">
          <el-select v-model="form.sex" placeholder="请选择用户性别">
            <el-option
              v-for="dict in dict.type.sys_user_sex"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-row>
          <el-col :span="12">
            <el-form-item label="岗位">
              <el-select v-model="form.postIds" multiple placeholder="请选择岗位">
                <el-option
                  v-for="item in postOptions"
                  :key="item.postId"
                  :label="item.postName"
                  :value="item.postId"
                  :disabled="item.status == 1"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="角色">
              <el-select v-model="form.roleIds" multiple placeholder="请选择角色">
                <el-option
                  v-for="item in roleOptions"
                  :key="item.roleId"
                  :label="item.roleName"
                  :value="item.roleId"
                  :disabled="item.status == 1"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="身份证" prop="idCard">
          <el-input v-model="form.idCard" placeholder="请输入身份证" />
        </el-form-item>
        <el-form-item label="身份证号地域" prop="idNumberRegion">
          <el-input v-model="form.idNumberRegion" placeholder="请输入身份证号地域" />
        </el-form-item>
        <el-form-item label="手机号码" prop="phoneNumber">
          <el-input v-model="form.phoneNumber" placeholder="请输入手机号码" />
        </el-form-item>
        <el-form-item label="地域" prop="region">
          <el-select v-model="form.region" placeholder="请输入地域">
            <el-option
              v-for="dict in dict.type.region"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="合同签订时间" prop="contractDate">
          <el-date-picker clearable
            v-model="form.contractDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择合同签订时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="合同截至日期" prop="contractLong">
          <el-date-picker clearable
            v-model="form.contractLong"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择合同截至日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="入职时间" prop="date">
          <el-date-picker clearable
            v-model="form.date"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择入职时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="社保缴纳情况" prop="typeOfEmployment">
          <el-input v-model="form.typeOfEmployment" placeholder="请输入社保缴纳情况"/>
        </el-form-item>
        <el-form-item label="用工类型" prop="typeOfMen">
          <el-select v-model="form.typeOfMen" placeholder="请选择人员类型">
            <el-option
              v-for="dict in dict.type.type_of_men"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="婚姻状态" prop="maritalStatus">
          <el-select v-model="form.maritalStatus" placeholder="请选择婚姻状态">
            <el-option
              v-for="dict in dict.type.marital_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="政治面貌" prop="politicalLandscape">
          <el-input v-model="form.politicalLandscape" placeholder="请输入政治面貌" />
        </el-form-item>
        <el-form-item label="住址" prop="address">
          <el-input v-model="form.address" placeholder="请输入住址" />
        </el-form-item>
        <el-form-item label="最高学历" prop="highEducationalLevel">
          <el-select v-model="form.highEducationalLevel" placeholder="请输入最高学历">
            <el-option
              v-for="dict in dict.type.education"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="毕业学校" prop="school">
          <el-input v-model="form.school" placeholder="请输入毕业学校" />
        </el-form-item>
        <el-form-item label="学制类型" prop="typeEducation">
          <el-input v-model="form.typeEducation" placeholder="请输入学制类型" />
        </el-form-item>
        <el-form-item label="专业" prop="major">
          <el-input v-model="form.major" placeholder="请输入专业" />
        </el-form-item>
        <el-form-item label="民族" prop="nation">
          <el-input v-model="form.nation" placeholder="请输入民族" />
        </el-form-item>
        <el-form-item label="紧急联系人" prop="emergencyContact">
          <el-input v-model="form.emergencyContact" placeholder="请输入紧急联系人" />
        </el-form-item>
        <el-form-item label="紧急联系人电话" prop="emergencyContactPhone">
          <el-input v-model="form.emergencyContactPhone" placeholder="请输入紧急联系人电话" />
        </el-form-item>
<!--        <el-form-item label="第一学历" prop="firstDegree">-->
<!--          <el-input v-model="form.firstDegree" placeholder="请输入第一学历" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="第二学历" prop="secondDegree">-->
<!--          <el-input v-model="form.secondDegree" placeholder="请输入第二学历" />-->
<!--        </el-form-item>-->

        <el-form-item label="开户行" prop="bank">
          <el-input v-model="form.bank" placeholder="请输入开户行" />
        </el-form-item>
        <el-form-item label="银行账号" prop="bankAccountNumber">
          <el-input v-model="form.bankAccountNumber" placeholder="请输入银行账号" />
        </el-form-item>
        <el-form-item label="爱好特长" prop="hobby">
          <el-input v-model="form.hobby" placeholder="请输入爱好特长" />
        </el-form-item>
        <el-form-item label="是否安排寝室" prop="dormitoryNeed">
          <el-input v-model="form.dormitoryNeed" placeholder="请输入是否安排寝室" />
        </el-form-item>
        <el-form-item label="寝室号" prop="dormitory">
          <el-input v-model="form.dormitory" placeholder="请输入寝室号" />
        </el-form-item>
        <el-form-item label="出生年月" prop="birthday">
          <el-date-picker clearable
            v-model="form.birthday"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择出生年月">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="其他" prop="other">
          <el-input v-model="form.other" placeholder="请输入其他" />
        </el-form-item>
        <el-form-item label="预留字段1" prop="Reserved1">
          <el-input v-model="form.Reserved1" placeholder="请输入预留字段1" />
        </el-form-item>
        <el-form-item label="预留字段2" prop="Reserved2">
          <el-input v-model="form.Reserved2" placeholder="请输入预留字段2" />
        </el-form-item>
        <el-form-item label="预留字段3" prop="Reserved3">
          <el-input v-model="form.Reserved3" placeholder="请输入预留字段3" />
        </el-form-item>
        <el-form-item label="预留字段4" prop="Reserved4">
          <el-input v-model="form.Reserved4" placeholder="请输入预留字段4" />
        </el-form-item>
        <el-form-item label="预留字段5" prop="Reserved5">
          <el-input v-model="form.Reserved5" placeholder="请输入预留字段5" />
        </el-form-item>
        <el-form-item label="预留字段6" prop="Reserved6">
          <el-input v-model="form.Reserved6" placeholder="请输入预留字段6" />
        </el-form-item>
        <el-form-item label="预留字段7" prop="Reserved7">
          <el-input v-model="form.Reserved7" placeholder="请输入预留字段7" />
        </el-form-item>
        <el-form-item label="预留字段8" prop="Reserved8">
          <el-input v-model="form.Reserved8" placeholder="请输入预留字段8" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listInformation, getInformation, delInformation, addInformation, updateInformation } from "@/api/Empment/information";
import {deptTreeSelect, getUser} from "@/api/system/user";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";

export default {
  name: "Information",
  dicts: ['marital_status', 'type_of_employment', 'type_of_men', 'sys_user_sex','region','education'],
  components: { Treeselect },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 部门名称
      deptName: undefined,
      // 部门树选项
      deptOptions: undefined,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: false,
      // 总条数
      total: 0,
      // 员工信息表格数据
      informationList: [],
      // 岗位选项
      postOptions: [],
      // 角色选项
      roleOptions: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userId: null,
        name: null,
        deptId: null,
        empNumber: null,
        sex: null,
        idCard: null,
        idNumberRegion: null,
        phoneNumber: null,
        region: null,
        contractDate: null,
        contractLong: null,
        date: null,
        typeOfEmployment: null,
        typeOfMen: null,
        maritalStatus: null,
        politicalLandscape: null,
        address: null,
        highEducationalLevel: null,
        school: null,
        major: null,
        nation: null,
        emergencyContact: null,
        emergencyContactPhone: null,
        firstDegree: null,
        secondDegree: null,
        typeEducation: null,
        bank: null,
        bankAccountNumber: null,
        hobby: null,
        dormitoryNeed: null,
        dormitory: null,
        birthday: null,
        other: null,
        Reserved1: null,
        Reserved2: null,
        Reserved3: null,
        Reserved4: null,
        Reserved5: null,
        Reserved6: null,
        Reserved7: null,
        Reserved8: null
      },
      // 表单参数
      form: {},
      defaultProps: {
        children: "children",
        label: "label"
      },
      // 表单校验
      rules: {
        name: [
          { required: true, message: "姓名不能为空", trigger: "blur" }
        ],
        date: [
          { required: true, message: "入职时间不能为空", trigger: "blur" }
        ],
        idCard: [
          { required: true, message: "身份证号不能为空", trigger: "blur" },
          { min: 18, max: 18, message: '身份证号长度必须为18 之间', trigger: 'blur' }
        ],
        phonenumber: [
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "请输入正确的手机号码",
            trigger: "blur"
          }
        ]
      },
      maxHeight: window.innerHeight * 0.8, // 表格最大高度占屏幕的80%
    };
  },
  watch: {
    // 根据名称筛选部门树
    deptName(val) {
      this.$refs.tree.filter(val);
    }
  },

  created() {
    this.getList();
    this.getDeptTree();
  },
  methods: {
    /** 查询员工信息列表 */
    getList() {
      this.loading = true;
      listInformation(this.queryParams).then(response => {
        this.informationList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 查询部门下拉树结构 */
    getDeptTree() {
      deptTreeSelect().then(response => {
        this.deptOptions = response.data;
      });
    },
    // 筛选节点
    filterNode(value, data) {
      if (!value) return true;
      return data.label.indexOf(value) !== -1;
    },
    // 节点单击事件
    handleNodeClick(data) {
      this.queryParams.deptId = data.id;
      this.handleQuery();
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        userId: null,
        name: null,
        empNumber: null,
        sex: null,
        idCard: null,
        idNumberRegion: null,
        phoneNumber: null,
        region: null,
        contractDate: null,
        contractLong: null,
        date: null,
        typeOfEmployment: null,
        typeOfMen: null,
        maritalStatus: null,
        politicalLandscape: null,
        address: null,
        highEducationalLevel: null,
        school: null,
        major: null,
        nation: null,
        emergencyContact: null,
        emergencyContactPhone: null,
        firstDegree: null,
        secondDegree: null,
        typeEducation: null,
        bank: null,
        bankAccountNumber: null,
        hobby: null,
        dormitoryNeed: null,
        dormitory: null,
        birthday: null,
        other: null,
        Reserved1: null,
        Reserved2: null,
        Reserved3: null,
        Reserved4: null,
        Reserved5: null,
        Reserved6: null,
        Reserved7: null,
        Reserved8: null,
        postIds: [],
        roleIds: []
      };
      this.resetForm("form");
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.userId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */

    handleAdd() {
      this.reset();
      getUser().then(response => {
      this.postOptions = response.posts;
      this.roleOptions = response.roles;
      this.open = true;
      this.title = "添加员工信息";
      });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.userId || this.ids
      //这里把原来的id改成了userid，其他的地方还是用id在查找
      getInformation(id).then(response => {
        this.form = response.data;
        this.postOptions = response.posts;
        this.roleOptions = response.roles;
        this.$set(this.form, "postIds", response.postIds);
        this.$set(this.form, "roleIds", response.roleIds);
        this.open = true;
        this.title = "修改员工信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateInformation(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addInformation(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.userId || this.ids;
      this.$modal.confirm('是否确认删除员工信息编号为"' + ids + '"的数据项？').then(function() {
        return delInformation(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('Empment/information/export', {
        ...this.queryParams
      }, `information_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
